package com.sanley.piss.model.exceptionUtil.json;


import com.sanley.piss.model.exceptionUtil.exception.BaseErrorInfoInterface;
import lombok.Getter;
import lombok.ToString;
import org.springframework.http.HttpStatus;



/**
 * Create By  on 2021/3/5.
 */
@ToString
@Getter
public enum  ResultEnum implements BaseErrorInfoInterface {

    success(HttpStatus.OK,200, "操作成功"),
    fail(HttpStatus.OK,1001, "操作失败"),
    loginSuccess(HttpStatus.OK,1002, "登录成功"),
    loginFail(HttpStatus.OK,1003, "用户名或密码错误"),
    userExist(HttpStatus.OK,1004, "用户名已存在"),
    pwdError(HttpStatus.OK,1005, "原密码错误"),
    quick(HttpStatus.OK,1006, "操作过快,请稍后再试"),
    nameExist(HttpStatus.OK,1007, "名称已存在"),
    notDelete(HttpStatus.OK,1008, "不可删除"),
    updateSuccess(HttpStatus.OK,1009, "修改成功"),
    updateFail(HttpStatus.OK,1010, "修改失败"),
    userDisabled(HttpStatus.OK,1011, "用户已禁用"),
    authorizationFail(HttpStatus.OK,1012, "授权失败"),
    userIsNull(HttpStatus.OK,1013, "用户不存在"),
    roleIsNull(HttpStatus.OK,1014, "用户无角色权限"),
    jobNumExist(HttpStatus.OK,1015, "工号已存在"),
    badRequest(HttpStatus.BAD_REQUEST,400, "错误的请求"),
    error(HttpStatus.INTERNAL_SERVER_ERROR,500, "内部服务器错误"),
    ;
    /**
     * 返回的Http状态码，符合http请求
     */
    private HttpStatus httpStatus;
    /**
     * 业务异常码
     */
    private Integer code;
    /**
     * 业务异常信息描述
     */
    private String message;

    ResultEnum(HttpStatus httpStatus, Integer code, String message) {
        this.httpStatus = httpStatus;
        this.code = code;
        this.message = message;
    }

    @Override
    public String getResultCode() {
        return code.toString();
    }

    @Override
    public String getResultMsg() {
        return message;
    }
}
